/*
	Prototype is developed by Benato Denis.
	Prototype is a project started on 23/09/2013.
	Prototype is release under LGPLv3 license.
	If you use part of Prototype software on other
	projects, you must copy this comment into the source
	code of the other projects, and quote Benato Denis 
	in the credits of the other software.
*/

#ifndef __PROGRAM_H__
#define __PROGRAM_H__

#include "Prototype.h"
#include "Memory.h"

struct ProgramInfo
{
	char name[21];
	char author[21];
	char description[121]; 
	unsigned short license;
};

struct Instruction
{
	unsigned char instruction;
	unsigned char data;
};

struct Redirections
{
	unsigned long Begin;
	unsigned long End;
	unsigned short Type; //0x00 = if, 0x01 = while
};

class Program
{
	public:
		void Load(char*);
		struct ProgramInfo* GetProgramInfo();
		struct PrototypeVersion* GetCompilerInfo();
		unsigned long GetInstructionsNumber();
		bool EndOfInstructions();
		void ExecuteInstruction();
		bool Executable();
		Program();
		~Program();
	private:
		Memory *ProgramMemory;
		bool Loaded, ProgramExecutable;
		struct ProgramInfo CurrentProgramInfo;
		struct PrototypeVersion CompiledPrototypeVersion;
		struct Instruction* Instructions;
		unsigned long InstructionsNumber, ExecutedInstructions, InstructionPointer, WastedTime;
		struct Redirections *ConditionalStructures;
		unsigned long ConditionalStructuresFound;
};

#endif
